home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-20 | 885 b | 69 lines | [TEXT/CWIE] |
- #include "OTList.h"
-
- void* OTLinkNextObject(void* obj, int linkOffset)
- {
- if (obj != nil)
- {
- OTLink* link = reinterpret_cast<OTLink*>(reinterpret_cast<char*>(obj) + linkOffset)->fNext;
-
- obj = link ? (reinterpret_cast<char*>(link) - linkOffset) : nil;
- }
-
- return obj;
- }
-
- void* OTLinkIndexObject(void* obj, int count, int linkOffset)
- {
- if (obj != nil)
- {
- OTLink* link = (OTLink*) ((char*) obj + linkOffset);
-
- do
- {
- if (count == 0)
- {
- return ((char*) link - linkOffset);
- }
- else if (count < 0)
- {
- break;
- }
- else
- {
- link = link->fNext;
- count -= 1;
- }
- }
- while (link != nil);
- }
-
- return nil;
- }
-
- /*
-
- class Foo
- {
- public:
- long xxx;
- OTLink fNextFoo;
- };
-
- typedef EmbeddedLinkPtr(Foo, fNextFoo) FooLinkPtr;
-
-
-
- static void test(void)
- {
- Foo anObject;
-
- FooLinkPtr link(&anObject);
-
- while (link)
- {
-
- link = link.Next();
- }
- };
-
- */